package com.julian.iteratorPattern;

import java.util.ArrayList;
import java.util.Iterator;

public class PancakeHouseIterator implements Iterator {

    int position = 0;

    ArrayList menuItems;

    public PancakeHouseIterator(ArrayList menuItems) {
        this.menuItems = menuItems;
    }


    @Override
    public boolean hasNext() {
        if (position >= menuItems.size() || menuItems.get(position) == null){
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        Object menuItem = menuItems.get(position);
        position++;
        return menuItem;
    }
}
